package library.hibernate.dto;

import java.util.Calendar;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Version;

@Entity
@Table(name = "app_user_details", catalog = "public")
public class UserDetails {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	private Long Id;

	@Column(name = "first_name", nullable = false)
	private String firstName;

	@Column(name = "last_name", nullable = false)
	private String lastName;

	@Column(name = "e_mail", nullable = true)
	private String eMail;

	@Column(name = "alt_e_mail", nullable = true)
	private String alternateEMail;

	@Column(name = "birth_date", nullable = true)
	private Date birthDate;

	@Column(name = "create_date", nullable = false)
	private Date createDate;

	@Version
	@Column(name = "modify_date", nullable = false)
	private Date modifyDate;

	@OneToOne
	@JoinColumn(name = "user_id")
	private User user;

	/*
	 * Constructors
	 */

	public UserDetails() {
	}

	public UserDetails(String firstName, String lastName, String eMail,
			String alternateEMail, Date birthDate) {

		Date currentDate = Calendar.getInstance().getTime();
		this.modifyDate = currentDate;
		this.createDate = currentDate;
		this.firstName = firstName;
		this.lastName = lastName;
		this.eMail = eMail;
		this.alternateEMail = alternateEMail;
		this.birthDate = birthDate;

	}
	
	public UserDetails(String firstName, String lastName, String eMail,
			String alternateEMail, Date birthDate, User user) {

		Date currentDate = Calendar.getInstance().getTime();
		this.modifyDate = currentDate;
		this.createDate = currentDate;
		this.firstName = firstName;
		this.lastName = lastName;
		this.eMail = eMail;
		this.alternateEMail = alternateEMail;
		this.birthDate = birthDate;
		this.user = user;

	}

	/*
	 * Getters and Setters
	 */

	public Long getId() {
		return Id;
	}

	public void setId(Long id) {
		Id = id;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String geteMail() {
		return eMail;
	}

	public void seteMail(String eMail) {
		this.eMail = eMail;
	}

	public String getAlternateEMail() {
		return alternateEMail;
	}

	public void setAlternateEMail(String alternateEMail) {
		this.alternateEMail = alternateEMail;
	}

	public Date getBirthDate() {
		return birthDate;
	}

	public void setBirthDate(Date birthDate) {
		this.birthDate = birthDate;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public Date getModifyDate() {
		return modifyDate;
	}

	public void setModifyDate(Date modifyDate) {
		this.modifyDate = modifyDate;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

}
